package com.aaa.service.impl;

import com.aaa.dao.TesterFPADao;
import com.aaa.entity.Tester;
import com.aaa.service.TesterFPAService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class TesterFPAServiceImpl implements TesterFPAService {
    @Autowired
    private TesterFPADao testerFPADao;
    @Override
    public Page selectTester(Tester tester) {
        Page<Tester> page =PageHelper.startPage(tester.getPage(),tester.getLimit());
      List<Tester> testerList  = testerFPADao.selectTester(tester);
      Page listPage= (Page) testerList;
        return listPage;
    }

    @Override
    public boolean deleteTesterById(Integer id) {
        int deleteTesterById = testerFPADao.deleteTesterById(id);
        if (deleteTesterById>0){
            return true;
        }
        return false;
    }

    @Override
    public boolean deleteTesterBatch(String id) {
        int deleteTesterBatch = testerFPADao.deleteTesterBatch(id);
        if (deleteTesterBatch>0){
            return true;
        }
        return false;
    }

    /**
    * @Author: WTH
    * @Description: 新增
    * @Date:2022-07-07 10:39
    * @Params:
    */
    @Override
    public boolean addTester(Tester tester) {
        int i = testerFPADao.addTester(tester);
        if(i>0){
            return true;
        }
        return false;
    }

    /**
    * @Author: WTH
    * @Description: 根据手机号查询
    * @Date:2022-07-07 10:42
    * @Params:
    */
    @Override
    public List<Tester> selectTesterByPhone(Tester tester) {
        List<Tester> testers = testerFPADao.selectTesterByPhone(tester);
        return testers;
    }

    @Override
    public Tester selectTesterById(Integer id) {
        Tester tester = testerFPADao.selectTesterById(id);
        if (tester!=null){
            return   tester;
        }
        return null;
    }
}
